<template>
    <mu-select :filterable="!!config.search" v-model="inSideValue" full-width>
        <mu-option v-for="(choice,index) in choices"  :key="index" :label="choice.label" :value="choice.value"></mu-option>
    </mu-select>
</template>

<script>
    export default {
        name: "EzSelect",
        props: {
            value: {},
            config: {}
        },
        data() {
            return {
                inSideValue: "",
                choices:[],
            }
        },
        mounted() {
            this.inSideValue = this.value
            //检查是否设置了数据接口，如果是则从接口获取数据
            if (this.config.api === ""){
                this.choices = this.config.choices
            }else {
                this.$http.post(this.config.api,this.config.apiParams,res=>{
                    this.choices = this.config.apiCbFunc(res.data.lists)
                })
            }

        },
        watch: {
            inSideValue(val) {
                this.$emit("input", val)
            }
        },
    }
</script>

<style scoped>

</style>